<template>
  <div>
 <el-table
    :data="tableData"
    stripe
    style="width: 100%">
    <el-table-column
      prop="userName"
      label="申请人姓名"
      >
    </el-table-column>
    <el-table-column
      prop="petName"
      label="宠物名称"
      >
    </el-table-column>
    <el-table-column
      prop="phone"
      label="联系方式">
    </el-table-column>
     <el-table-column
      prop="adress"
      label="地址"
      >
    </el-table-column>
     <el-table-column
      prop="email"
      label="邮箱">
    </el-table-column>
   <el-table-column
      prop="remark"
      label="备注">
    </el-table-column>
     <el-table-column
      prop="apply"
      label="审核状态">
        <template slot-scope="scope">
        <el-tag
          :type="scope.row.apply === 0 ? 'primary' : 'success'"
          disable-transitions>{{scope.row.apply === 0 ? '未通过' : '已通过'}}</el-tag>
      </template>
    </el-table-column>
     <el-table-column
      label="操作"
     >
      <template slot-scope="scope">
       <el-popconfirm
  confirm-button-text='确定'
  cancel-button-text='取消'
  icon="el-icon-info"
  icon-color="green"
  title="确定通过审核吗？"
  @confirm="updateApply(scope.row)"
>
  <el-button slot="reference" type="primary" round  style="margin-left:10px">审核通过</el-button>
</el-popconfirm>
      </template>
    </el-table-column>
  </el-table>
    <el-empty :image-size="200" v-if="flag==false"></el-empty>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="pageNo"
      :page-sizes="[10, 20, 30, 40]"
      :page-size="pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total">
    </el-pagination>
  </div>
</template>

<script>
export default {
  name: 'AllProcess',
  data () {
    return {
      flag: false,
      tableData: {},
      apply: '',
      pageNo: 1,
      total: 0,
      pageSize: 10
    }
  },
  methods: {
    updateApply (row) {
      row.apply = 1
      this.request.post('/adopt/updateApply', row).then(res => {
        if (res.code === '200') {
          this.$message.success('操作成功')
          this.loadGet()
        } else {
          this.$message.error('网络异常')
        }
      })
    },
    loadGet () {
      this.apply = 0
      this.request.post('/adopt/getAdopt' + '/' + this.apply + '/' + this.pageNo + '/' + this.pageSize).then(res => {
        if (res.code === '200') {
          this.flag = true
          this.tableData = res.data.list
          this.total = res.data.total
        } else {
          this.flag = false
          this.$message.error('网络异常')
        }
      })
    }

  },
  mounted () {
    this.loadGet()
  }
}
</script>

<style>

</style>
